package com.lengyue.imakiba.show;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;

import com.jfinal.core.Controller;
import com.lengyue.imakiba.data.Anime;
import com.lengyue.imakiba.data.AnimeInterface;
import com.lengyue.imakiba.data.Episode;
import com.lengyue.imakiba.data.EpisodeInterface;
import com.lengyue.imakiba.data.Type;
import com.lengyue.imakiba.logic.AnimeLogic;
import com.lengyue.imakiba.logic.EpisodeLogic;
import com.lengyue.imakiba.logic.TypeLogic;

public class AnimeInfo extends Controller implements AnimeInterface,EpisodeInterface{
	public void index()
	{
		//导航栏动漫类型
		int animeId = getParaToInt("animeId");
		Anime anime = Anime.dao.findById(animeId);
		//设置动漫声优
		anime.put("cvs", anime.getCV());
		//动漫剧集
		List<Episode> episodes = EpisodeLogic.getEpisodeByAnimeId(animeId);
		//动漫类型
		List<Type> types = TypeLogic.getAllTypesAndSort();
		//与当前动漫类型相同的动漫推荐
		List<Anime> similarAnimes = AnimeLogic.getSimilarAnimes(1, 5, animeId).getList();
		LinkedHashMap<String,ArrayList<HashMap<String,String>>> episodeUrls = EpisodeLogic.getEpisodeUrls(episodes,urlNames);
		setAttr("anime", anime);
		setAttr("episodeUrls", episodeUrls);
		setAttr("types", types);
		setAttr("similarAnimes", similarAnimes);
		setAttr("coverPath", coverPath);
		render("/WEB-INF/freeMarkerTemplete/anime_info.ftl");
	}
}
